package com.deepclassifieds.daas.api;

import com.deepclassifieds.daas.api.xsd.Database;
import com.deepclassifieds.daas.api.xsd.Databases;
import com.deepclassifieds.daas.api.xsd.Record;
import com.deepclassifieds.daas.api.xsd.Shard;
import com.deepclassifieds.daas.api.xsd.Shards;
import com.deepclassifieds.daas.api.xsd.Table;
import com.deepclassifieds.daas.api.xsd.Tables;
import com.deepclassifieds.daas.common.Name;

/**
 * <b>DDL:</b>
 * <p><code>POST /daas/create/{database}</code> - CREATE DATABASE</p>
 * <p><code>POST /daas/drop/{database}</code> - DROP DATBASE</p>
 * <p><code>POST /daas/{database}/create/{table}</code> - CREATE TABLE using <code>&lt;columns&gt;</code> POST payload</p>
 * <p><code>POST /daas/{database}/drop/{table}</code> - DROP TABLE</p>
 * <p><code>POST /daas/{database}/alter/{table}/add/column</code> - ADD COLUMN using <code>&lt;column&gt;</code> POST payload</p>
 * <p><code>POST /daas/{database}/drop/{table}/drop/column/{column}</code> - DROP COLUMN</p>
 * <b>DML:</b>
 * <p><code>GET  /daas/{database}/{shard[,shard]}/{table}/256</code> - SELECT BY UID</p>
 * <p><code>GET  /daas/{database}/{shard[,shard]}/{table}?where=eq(id,10243204)</code> - SELECT WHERE</p>
 * 
 * @author nbarkhatov
 *
 */
public interface DaasService {
	
	//
	// DDL
	//  

	Databases  getDatabases();
	Database   getDatabaseByName(Name databaseName);
	
	Shards     getShards();
	Shard      getShardByNumber(int shardNumber);

	Tables     getTables(Database database);
	Table      getTableByName(Database database, Shard shard, Name tableName);
	
	
	//
	// Expression
	//
	
	DaasExpressionBuilder createExpressionBuilder();
	
	//
	// DML
	//
	
	Record     insertRecord(Database database, Shard shard, Table table, Record record);
	
	Record     selectRecordByUID (Database database, Table table, DaasUID daasUID);

	void       updateRecord(Database database, Shard shard, Table table, Record record);
	
	void       deleteRecordByUID (Database database, Table table, DaasUID daasUID);
	
}
